package toy.keli.edic.data.file

/**
 * 日志文件
 */
class Log(val dir:String,val logName:String) :Base {
    companion object {
        /**
         * 搜索单词缺失的单词（单词词典中找不到但是网络搜索中获取到了）
         * 记录以备后续词典补充
         */
        fun searchWordLost(word: String) {
            Log("searchWord","Lost.txt").apply{
                add(word)
                val losts = gets().map { it.get(1) }.toHashSet().toArray()
                Net.putLostAll(losts as Array<String>)
            }

        }
        /**
         * 搜索单词失败
         */
        fun searchWordErr(word: String) {
            Log("searchWord","Err.txt").add(word)
        }
    }

    override fun file(): String {
        return dir+"/"+logName
    }

    fun add(vararg cols:String){
        append(date(),cols.joinToString("\t"))
    }
}